package com.soft.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.soft.entity.Orderlistdetails;

@Mapper
public interface OrderlistdetailsMapper extends BaseMapper<Orderlistdetails> {

    @Update("UPDATE food SET food_count = food_count + #{count} WHERE food_name = #{foodName}")
    int restoreStockByName(@Param("foodName") String foodName, @Param("count") Long count);

    @Update("UPDATE food SET food_count = food_count - #{count} WHERE food_name = #{foodName} AND food_count >= #{count}")
    int reduceStockByName(@Param("foodName") String foodName, @Param("count") Long count);
}
